package com.lark.utils;

import atlantafx.base.theme.PrimerDark;
import com.alibaba.fastjson2.JSONObject;
import com.lark.model.SettingModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

/**
 * json操作工具类
 */
@Slf4j
public final class JsonUtil {

    /**
     * 解析JSON文件为对象
     *
     * @param json    文件路径
     * @param objectClass
     * @return JSON字符串
     */
    public static <T> T parseJsonToClass(String json, Class<T> objectClass) {
        if (StringUtils.isNotBlank(json)) {
            return JSONObject.parseObject(json, objectClass);
        }
        return null;
    }

    public static void main(String[] args) {
        SettingModel settingModel = new SettingModel();
        settingModel.setTheme(new PrimerDark().getUserAgentStylesheet());
        settingModel.setWidth(850d);
        settingModel.setHeight(500d);
        settingModel.setTrayEnabled(true);
//        FileUtil.saveFile("setting/setting.json", JSONObject.toJSONString(settingModel));
    }
}
